<template>
  <div class="all">
    <div class="add-nav">
      <ul>
        <li class="list">收益分成设置</li>
      </ul>

      <div class="Param">
        <el-form :model="proP">
            <el-form-item label="普通用户分成">
                <el-input size="small" v-model="proP.ordinaryProp"></el-input>%
                 <font color="gray">请输入普通用户分成百分比</font>
            </el-form-item>
            <el-form-item label="工会用户分成" >
                <el-input size="small" v-model="proP.unionProp"></el-input>%
                 <font color="gray">请输入工会用户分成百分比</font>
            </el-form-item>
            <el-form-item label="普通用户税率">
                <el-input size="small" v-model="proP.ordinaryTax"></el-input>%
                 <font color="gray">请输入普通用户税率百分比</font>
            </el-form-item>
        </el-form>

      </div>
      <el-button type="primary" @click="Submit">确定</el-button>

      </div>
      </div>
</template>

<script>
  import Cookies from 'js-cookie'
  import {proportionGet,proportionUpdate} from '@/utils/API'
export default{
    inject:["reload"],
  data(){
    return{
      proP:{
        ordinaryProp:'',
        unionProp:'',
        ordinaryTax:''
      },
    }
  },
  methods:{
    Submit(){
        const ordinaryProp=this.proP.ordinaryProp>0&&this.proP.ordinaryProp<100
        const unionProp=this.proP.unionProp>0&&this.proP.unionProp<100
        const ordinaryTax=this.proP.ordinaryTax>0&&this.proP.ordinaryTax<100
          if(ordinaryTax&&unionProp&&ordinaryProp){
          const data={
            adminName:Cookies.get('adminName'),
            token:Cookies.get('token'),
            ordinaryProp:this.proP.ordinaryProp,
            unionProp:this.proP.unionProp,
            ordinaryTax:this.proP.ordinaryTax
          }
          proportionUpdate(data).then(res=>{
            if(res.code==0){
              this.$message.success('修稿成功')
                this.reload()
            }
          })
          }else{
            this.$message.error('请输入正确的数值')
          }

    },
    Postdata(e){
      const admin={
        adminName:Cookies.get('adminName'),
        token:Cookies.get('token')
      }
       proportionGet(admin).then(res=>{
         this.proP=res.data
       })
    }
  },
  mounted(){
    this.Postdata()
  }
  }
</script>

<style lang="scss" scoped src = "../../css/system.css">

</style>
